﻿<customWindow:BlackStyleChildWindow 
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
           x:Class="MediaBrowserSL.RIA.Views.ChildWindowAuthentication"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:customWindow="http://www.sebastien-alves.fr/jadeToolsSLWindows"
           xmlns:jadeControls="http://www.sebastien-alves.fr/jadeToolsSLControls" 
           xmlns:bindingHelpers="clr-namespace:JulMar.Siverlight.Helpers.BindingHelpers;assembly=JulMar.Siverlight.Helpers"
           xmlns:ConvertersJulmar="clr-namespace:JulMar.Silverlight.Converters;assembly=JulMar.Siverlight.Helpers"
           HasCloseButton="False">

    <controls:ChildWindow.DataContext>
        <Binding Mode="OneWay" Path="Authentication" Source="{StaticResource Locator}"/>
    </controls:ChildWindow.DataContext>

    <controls:ChildWindow.Resources>
        <ConvertersJulmar:NotBooleanToVisibilityConverter x:Key="NotBooleanToVisibilityConverter" />
    </controls:ChildWindow.Resources>

    <Grid x:Name="WindowContentPresenter">

        <Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition  />
            </Grid.RowDefinitions>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="170"/>
                </Grid.ColumnDefinitions>

                <sdk:ValidationSummary x:Name="vs" Grid.Row="0" Grid.ColumnSpan="2"/>

                <sdk:Label Content="Identifiant : " Name="lbLogin" Grid.Row="1" Grid.Column="0" />
                <TextBox Name="txLogin" Margin="0,0,0,5" Height="22" Text="{Binding Login, Mode=TwoWay}" 
                     bindingHelpers:BindingTextHelper.UpdateSourceOnChange="True" MaxLength="8" Grid.Row="1" Grid.Column="1" />

                <sdk:Label Content="Mote de passe : " Name="lbPass" Grid.Row="2" Grid.Column="0" />
                <PasswordBox Name="txPass" Height="22" Password="{Binding Password, Mode=TwoWay}" MaxLength="10"
                         bindingHelpers:BindingPasswordHelper.UpdateSourceOnChange="True" Grid.Row="2" Grid.Column="1" />

            </Grid>

            <Grid Grid.Row="1" HorizontalAlignment="Stretch" Margin="0,10,0,0">

                <StackPanel  Orientation="Vertical" HorizontalAlignment="Left">
                    <sdk:Label Content="Pas encore inscrit ?" FontWeight="Bold" HorizontalAlignment="Left" />
                    <HyperlinkButton x:Name="frontButton" Content="S'enregistrer" Command="{Binding GoToBackCommand}" HorizontalAlignment="Left" />
                </StackPanel>
                <Grid HorizontalAlignment="Right" Width="72">
                    <Button x:Name="loginButton" Content="Connexion" Command="{Binding LogCommand}" Height="26"/>
                    <jadeControls:Loading IsLoading="{Binding IsLoading}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Grid>

            </Grid>
        </Grid>

        <Grid Margin="5">

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition  />
            </Grid.RowDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="200"/>
                    <ColumnDefinition Width="28"/>
                </Grid.ColumnDefinitions>

                <sdk:Label Content="Nom : " Name="lbFirstName" Grid.Row="0" Grid.Column="0"  />
                <TextBox Name="txFirstName" Margin="0,0,0,5" Height="22" MaxLength="100" Grid.Row="0" Grid.Column="1" 
                         Text="{Binding NewUser.FirstName, Mode=TwoWay, ValidatesOnDataErrors=True}" bindingHelpers:BindingTextHelper.UpdateSourceOnChange="True"  />

                <sdk:Label Content="Prenom : " Name="lbLastName" Grid.Row="1" Grid.Column="0" />
                <TextBox Name="txLastName" Margin="0,0,0,5" Height="22" MaxLength="100" Grid.Row="1" Grid.Column="1" 
                         Text="{Binding NewUser.LastName, Mode=TwoWay, ValidatesOnDataErrors=True}" bindingHelpers:BindingTextHelper.UpdateSourceOnChange="True"/>

                <sdk:Label Content="Identifiant : " Name="lbRegisterLogin" Grid.Row="2" Grid.Column="0" />
                <TextBox Name="txRegisterLogin" Margin="0,0,0,5" Height="22" MaxLength="8" Grid.Row="2" Grid.Column="1" 
                         Text="{Binding NewUser.Login, Mode=TwoWay, ValidatesOnDataErrors=True}" bindingHelpers:BindingTextHelper.UpdateSourceOnChange="True"/>
                <sdk:DescriptionViewer Description="L'identifiant doit contenir 8 caractéres" Grid.Row="2" Grid.Column="2"
                                       Visibility="{Binding ExistLoginProcess,  Converter={StaticResource NotBooleanToVisibilityConverter}}"/>
                <jadeControls:Loading IsLoading="{Binding ExistLoginProcess}" HorizontalAlignment="Center" VerticalAlignment="Stretch" Grid.Row="2" Grid.Column="2" Margin="2,0,0,0" />

                <sdk:Label Content="Mote de passe : " Name="lbRegisterPass" Grid.Row="3" Grid.Column="0" />
                <PasswordBox Name="txRegisterPass" Height="22" MaxLength="10" Grid.Row="3" Grid.Column="1"
                             Password="{Binding NewUser.Password, Mode=TwoWay, ValidatesOnDataErrors=True}" bindingHelpers:BindingPasswordHelper.UpdateSourceOnChange="True"/>
                <sdk:DescriptionViewer Description="Le mot de passe doit contenir 10 caractéres" Grid.Row="3" Grid.Column="2"/>

            </Grid>

            <Grid Grid.Row="1" HorizontalAlignment="Stretch" Margin="0,10,0,0">

                <StackPanel  Orientation="Vertical" HorizontalAlignment="Left">
                    <sdk:Label Content="Déjà inscrit ?" FontWeight="Bold" />
                    <HyperlinkButton Grid.Row="1" x:Name="backButton" Content="Retour à la connexion" Command="{Binding GoToFrontCommand}" />
                </StackPanel>
                <Button x:Name="registerButton" Content="OK" Command="{Binding RegisterCommand}" HorizontalAlignment="Right" Width="60" Height="26"/>
            </Grid>

        </Grid>

    </Grid>
</customWindow:BlackStyleChildWindow>